﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HangYeLX.aspx.cs" Inherits="Web.Pages.YongShui.JiChuXX.HangYeLX" Theme="Default"  ValidateRequest="false" %>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>



<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../JS/AddEditCancel.js"></script>
    <script src="../../../JS/jquery.js"></script>
     <script type="text/javascript">
         function keyEnter(index) {
             var key = event.keyCode;
             if (key == 13) {
                 var controls = new Array();
                 controls[0] = document.getElementById("txtSheShuiDXFLDM_I");
                 controls[1] = document.getElementById("txtSheShuiDXFLMC_I");
                 controls[2] = document.getElementById("txtHangYeLXFLBM_I");
                 controls[3] = document.getElementById("txtHangYeLXFLMC_I");
                 index = index + 1;
                 if (index == controls.length) {
                     index = 0;
                 }
                 controls[index].focus();
             }
         }

         function display(op, id) {
             hdCollection.Set("ID", id);
             if (op == "add") {
                 btnAdd.SetVisible(false);
                 lblOperateTip.SetText("添加");
                 txtSheShuiDXFLDM.SetText("");
                 txtSheShuiDXFLDM.SetEnabled(true);
                 txtSheShuiDXFLMC.SetText("");
                 txtSheShuiDXFLMC.SetEnabled(true);
                 txtHangYeLXFLBM.SetText("");
                 txtHangYeLXFLBM.SetEnabled(true);
                 txtHangYeLXFLMC.SetText("");
                 txtHangYeLXFLMC.SetEnabled(true);
                 listCover(true, "divList");
                 $("#GridViewContentTable").show();
                 txtSheShuiDXFLDM.Focus();
             }
             else if (op == "edit") {
                 btnAdd.SetVisible(false);
                 lblOperateTip.SetText("修改");
                 txtSheShuiDXFLDM.SetEnabled(false);
                 txtSheShuiDXFLMC.SetEnabled(true);
                 txtHangYeLXFLBM.SetEnabled(true);
                 txtHangYeLXFLMC.SetEnabled(true);
                 listCover(true, "divList");
                 $("#GridViewContentTable").show();
                 ASPxCallback1.PerformCallback("info");
             }
             else {
                 $("#GridViewContentTable").hide();
                 btnAdd.SetVisible(true);
                 listCover(false, "divList");
             }
         }

         function del(id) {
             hdCollection.Set("ID", id);
             if (confirm("确认删除吗？")) {
                 ASPxCallback1.PerformCallback("del");
             }
             else {
                 hdCollection.Set("ID", -1);
             }
         }

         function save() {
             if (txtSheShuiDXFLDM.GetText() == "") {
                 alert("涉水对象分类代码，不能为空！");
                 txtSheShuiDXFLDM.Focus();
                 return;
             }
             if (!isAllNum(txtSheShuiDXFLDM.GetText()))
             {
                 alert("你输入的涉水对象分类代码格式不正确，请输入数字类型！");
                 txtSheShuiDXFLDM.Focus();
                 return;
             }
             if (txtSheShuiDXFLMC.GetText() == "") {
                 alert("涉水对象分类名称不能为空！");
                 txtSheShuiDXFLMC.Focus();
                 return;
             }
             if (txtHangYeLXFLBM.GetText() == "") {
                 alert("行业类型编码不能为空！");
                 txtHangYeLXFLBM.Focus();
                 return;
             }
             if (!isAllNum(txtHangYeLXFLBM.GetText())) {
                 alert("你输入的行业类型编码格式不正确，请输入数字类型！");
                 txtHangYeLXFLBM.Focus();
                 return;
             }
             if (txtHangYeLXFLMC.GetText() == "") {
                 alert("行业类型名称不能为空！");
                 txtHangYeLXFLMC.Focus();
                 return;
             }
             ASPxCallback1.PerformCallback("save");
         }

         function ASPxCallback1Complete(rs) {
             var arr = rs.split('|');
             var type = arr[0];
             var state = arr[1];
             var specialIdentity = arr[2];
             var msg = arr[3].split('-');
             if (msg[0] == 'True') {
                 alert(msg[1]);
             }
             hdCollection.Set("type", type);
             if (state == 'True') {
                 if (type == "info") {
                     //加载信息
                     txtSheShuiDXFLDM.SetText(arr[4]);
                     txtSheShuiDXFLMC.SetText(arr[5]);
                     txtHangYeLXFLBM.SetText(arr[6]);
                     txtHangYeLXFLMC.SetText(arr[7]);
                     txtSheShuiDXFLMC.Focus();
                 }
                 else if (type == "del") {
                     gvList.PerformCallback();
                 }
                 else if (type == "save") {
                     display("init", -1);
                     //记录当前操作对象,用于刷新列表后定位
                     hdCollection.Set("OperateID", specialIdentity);
                     gvList.PerformCallback();
                 }
             }
             else {

             }
         }
         function begincall() {
             loadpanel1.Show();
         }
         function endcall() {
             loadpanel1.Hide();
             //定位添加或修改的记录
             var oid = hdCollection.Get("OperateID");
             var index = -1;
             if (oid != -1 && typeof (oid) != undefined) {
                 for (var i = 0; i < gvList.GetVisibleRowsOnPage() ; i++) {
                     if (gvList.GetRowKey(i) == oid) {
                         index = i;
                     }
                 }
                 if (index != -1) {
                     gvList.SetFocusedRowIndex(index);
                     gvList.MakeRowVisible(index);
                     hdCollection.Set("OperateID", -1);
                 }
             }
         }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            行业类型
        </div>
            <dx:ASPxHiddenField ID="hdCollection" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
            <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
             <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="loadpanel1" runat="server" ContainerElementID="gvList" Modal="true" Theme="Metropolis" ShowImage="false" Text="加载中" ></dx:ASPxLoadingPanel>
        <div style="height: 3px;"></div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>

                <div id="divList" align="center">
                    <div>
                        <dx:ASPxGridView ID="gvList" ClientInstanceName="gvList" runat="server" AutoGenerateColumns="False" KeyFieldName="ID" Theme="Aqua1"  Width="100%" OnCustomCallback="gvList_CustomCallback">
                            <Columns>
                                <dx:GridViewDataTextColumn FieldName="S_SHESHUIDXFLDM" Caption="涉水对象分类代码" Width="20%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_SHESHUIDXFLMC" Caption="涉水对象分类名称" Width="23%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_HANGYELEIXBM" Caption="行业类型编码" Width="15%">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn FieldName="S_HANGYELEIXMC" Caption="行业类型名称">
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="5%">
                                    <DataItemTemplate>
                                        <a href="#" onclick="display('edit','<%#Eval("ID")%>')">修改</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                                <dx:GridViewDataTextColumn Width="5%">
                                    <DataItemTemplate>
                                       <a href="#" onclick="del('<%#Eval("ID")%>')">删除</a>
                                    </DataItemTemplate>
                                </dx:GridViewDataTextColumn>
                            </Columns>
                            <Settings  VerticalScrollableHeight= "315" VerticalScrollBarMode="Auto"  />
                            <ClientSideEvents  Init="function(s,e){AdjustSize(300,gvList);}" BeginCallback="function(s,e){begincall();}" EndCallback="function(s,e){endcall();}"  />
                        </dx:ASPxGridView>
                    </div>
                    <div style="height: 3px;"></div>
                    <div style="text-align: right">
                        <hr />
                        <dx:ASPxButton ID="btnAdd" ClientInstanceName="btnAdd" runat="server" Text="添加" AutoPostBack="false"  ClientSideEvents-Click="function(s,e){display('add',-1)}"  UseSubmitBehavior="false">
                        </dx:ASPxButton>
                    </div>
                    <div id="GridViewContentTable" style="display:none;">
                        <div class="tabletitle1" align="center">
                            <dx:ASPxLabel ID="lblOperateTip" runat="server" ClientInstanceName="lblOperateTip" Text="添加"></dx:ASPxLabel>
                        </div>
                        <table style="width: 80%; margin: auto;">
                            <tr>
                                <td align="right" style="width: 40%">涉水对象分类代码：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtSheShuiDXFLDM" ClientInstanceName="txtSheShuiDXFLDM" runat="server" Width="60%" MaxLength="15">                                        
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(txtSheShuiDXFLMC);}"
                                         />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">涉水对象分类名称：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtSheShuiDXFLMC" ClientInstanceName="txtSheShuiDXFLMC" runat="server" Width="100%" MaxLength="30">                                       
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(txtHangYeLXFLBM);}"
                                         />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">行业类型编码：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtHangYeLXFLBM" ClientInstanceName="txtHangYeLXFLBM" runat="server" Width="60%" MaxLength="15">                                      
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(txtHangYeLXFLMC);}"
                                         />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">行业类型名称：
                                </td>
                                <td>
                                    <dx:ASPxTextBox ID="txtHangYeLXFLMC" ClientInstanceName="txtHangYeLXFLMC" runat="server" Width="100%" MaxLength="30">                                        
                                        <ClientSideEvents  KeyPress="function(s,e){OnKeyNext(btnSave);}"
                                         />
                                    </dx:ASPxTextBox>
                                </td>
                            </tr>
                        </table>
                        <table id="GridViewButtonTable" runat="server" style="width:100%">
                            <tr>
                                <td><hr /></td>
                            </tr>
                            <tr>
                                <td style="text-align: right;">
                                    <dx:ASPxButton ID="btnSave" ClientInstanceName="btnSave" runat="server" Text="保存" UseSubmitBehavior="false" AutoPostBack="false">
                                        <ClientSideEvents Click="function(s, e) {
	                                               save();
                                        }" />
                                    </dx:ASPxButton>
                                    <dx:ASPxButton  ID="btnCancel" runat="server" Text="放弃" AutoPostBack="false" UseSubmitBehavior="false" >
                                        <ClientSideEvents  Click="function(s,e){display('init',-1);}"/>
                                        </dx:ASPxButton>
                                </td>
                            </tr>
                        </table>                        
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>
